import linear_algebra as la

if __name__ == "__main__":
    # test base
    print("test base")
    A = la.Matrix([[1, 2, 4], [3, 7, 2], [2, 3, 3]])
    b = la.Vector([7, -11, 1])

    ls = la.LinearSystem(A, b)
    ls.gauss_jordan_elimination()
    ls.fancy_print()

    # test ext
    print("test ext")
    A1 = la.Matrix([[1, -1, 2, 0, 3], 
                    [-1, 1, 0, 2, -5], 
                    [1, -1, 4, 2, 4],
                    [-2, 2, -5, -1, -3]])
    b1 = la.Vector([1, 5, 13, -1])
    ls1 = la.LinearSystemExt(A1, b1)
    ls1.gauss_jordan_elimination()
    ls1.fancy_print()

    # test no solution
    print("test no solution")
    A2 = la.Matrix([[2, 2], 
                    [2, 1], 
                    [1, 2]])
    b2 = la.Vector([3, 2.5, 7])
    ls2 = la.LinearSystemExt(A2, b2)
    isHasSolution = ls2.gauss_jordan_elimination()
    if not isHasSolution:
        print("No Solution!")
    ls2.fancy_print()

    print("base matrix")
    A.fancy_print()
    print("inverse matrix")
    invA = la.inv(A)
    invA.fancy_print()
    print("inverse matrix * matrix")
    A.dot(invA).fancy_print()
    invA.dot(A).fancy_print()

    print(la.rank(A2))